package d6_groupChat;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",4865);
        OutputStream os= socket.getOutputStream();
        ClientReaderThread crt = new ClientReaderThread(socket);
        crt.start();

        //把字节输出流包装成数据输出流
        DataOutputStream dos= new DataOutputStream(os);
        Scanner sc= new Scanner(System.in);
        while (true) {
            System.out.println("Enter command: ");
            String command = sc.nextLine();
            dos.writeUTF(command);
            dos.flush();
            if(command.equals("exit")){
                break;
            }
        }
        dos.close();
        socket.close();
    }
}
